package ru.aslanov.schedule.client.ds;

import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.fields.DataSourceTextField;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * Created: Mar 4, 2010 5:25:03 PM
 *
 * @author Sergey Aslanov
 */
public class UserGCalendarsDS extends ChildDS {
    private static Map<String, DataSource> instances = new HashMap<String, DataSource>();

    public static DataSource getInstance(String scheduleKey) {
        DataSource dataSource = instances.get(scheduleKey);
        if (dataSource == null) {
            dataSource = new UserGCalendarsDS(scheduleKey, null);
            instances.put(scheduleKey, dataSource);
        }
        return dataSource;
    }

    private UserGCalendarsDS(String scheduleKey, InputLangProvider inputLangProvider) {
        super("UserGCalendar", scheduleKey, "schedule", inputLangProvider);

        DataSourceField name = new DataSourceTextField("name");

        DataSourceField eventFeed = new DataSourceTextField("calendarId");
        eventFeed.setPrimaryKey(true);
        eventFeed.setHidden(true);

        setFields(eventFeed, name);
    }
}
